package com.media.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 文件访问
 */
@Configuration
public class FilePathConfig implements WebMvcConfigurer {

    @Resource
    MediaCaptorLiveConfig mediaCaptorLiveConfig;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/resources/**") //虚拟url路径
                .addResourceLocations("file:" + mediaCaptorLiveConfig.getResourcesSavePath() + "/"); //真实本地路径
    }
}
